# 字典数据类型

dict1 = {"tom": 60, "mary": 70, "sq": 80}
print(dict1)

# 返回所有的key值
print(dict1.keys())

# 返回所有项
print(dict1.items())

# 获取 key 对应的值 没有改key 返回 None
print(dict1.get("to1m"))
# 这种方式如果没有对应的key 会报错
print(dict1["tom"])

# 删除对应的kv
print(dict1.pop("sq"))
print(dict1)

# 遍历
for key in dict1:
    print(key, dict1[key])

print("-------------")

for k, v in dict1.items():
    print(k, v)


















